package from;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;

public class ButtonPage extends WebPage {
    public ButtonPage(){
        super();

        add(new FeedbackPanel("feedback2"));

        Form form = new Form("form"){
            protected void onSubmit(){
                info("form.onSubmit executed");
            }
            //点击button 调用 Form 的 onSubmit 事件
        };

        Button button1 = new Button("button1"){
            protected void onSubmit(){
                info("button1.onSubmit executed");
            }
        };
        form.add(button1);
        //点击button1 调用 button1 的 onSubmit 事件>>再调form的

        Button button2 = new Button("button2"){
            protected void onSubmit(){
                info("button2.onSubmit executed");
            }
        };
        button2.setDefaultFormProcessing(false);
        //点击button2 会跳过调用 Form 的 onSubmit 事件 ，只调用 button2 的 onSubmit 事件
        form.add(button2);

        add(form);
    }
}
